/*
 * @Author: zhangxiao
 * @Email: zhangxiao0125@163.com
 * @Date: 2020-07-02 14:03:10
 * @Last Modified by: zhangxiao
 * @Last Modified time: 2020-07-03 09:56:38
 * @Description: 文档，网页播放页面
 */


import 'package:auto_orientation/auto_orientation.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_code_framework/base/base_main_tabbar.dart';
import 'package:flutter_code_framework/base/base_widget.dart';
import 'package:flutter_code_framework/route/route_transition.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';

class ResourcesWebview extends BaseWidget {
  String resourceUrl;
  String title;
  ResourcesWebview({Key key,this.resourceUrl,this.title}) : super(key: key);

  @override
  BaseWidgetState<BaseWidget> getState() {
    return _ResourcesWebviewState();
  }
}

class _ResourcesWebviewState extends BaseWidgetState<ResourcesWebview> {
  FlutterWebviewPlugin flutterWebviewPlugin = FlutterWebviewPlugin();
double lineProgress = 0.0;
  @override
  Widget buildWidget(BuildContext context) {
     //全屏 强制横屏
    AutoOrientation.landscapeRightMode();
    //启动横屏陀螺仪
    AutoOrientation.landscapeAutoMode();
   return WillPopScope(child: SafeArea(
     child: WebviewScaffold(
       withZoom: true,    
       scrollBar: true,   
       withJavascript: true,
       useWideViewPort: true,
       displayZoomControls:true,
       withOverviewMode: true,
       url:widget.resourceUrl
    ),
    bottom: true,
    left: true,
    right: true,
    top: true
   // ignore: missing_return
   ),onWillPop:(){
     RouteTransition(BaseMainTabbarPage()).pushAndRemoveUntilTransRoute(context);
   });
  }

 @override
 void initState() { 
   super.initState();
 }
  @override
  void onCreate() {
     setAppTopNavBarVisible(true);
     setTopNavTitle(widget.title);
  }

  @override
  void onPause() {
  }

  @override
  void onResume() {
  }
  
  @override
  void dispose() {
    super.dispose();
    AutoOrientation.portraitDownMode();
    AutoOrientation.portraitUpMode();
  }
}